package com.edge.pbx.view;

import android.content.Context;
import android.graphics.PorterDuff;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;

import androidx.annotation.Nullable;

import com.qztech.utils.YzDebug;

/**
 * Copyright (C), 深圳市东乘电子科技有限公司
 * Carate By YangZhong
 */
public class PbxCircleRadioSeekBar extends PbxCircleSeekBar {

    private boolean isChecked = false;

    public PbxCircleRadioSeekBar(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }


    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {

        setSelected(checked);

        isChecked = checked;
        if (mDrawableTitle != null){
            mDrawableTitle.setState(checked?SELECTED_STATE_SET:EMPTY_STATE_SET);
            postInvalidate();

        }

    }




//    @Override
//    public boolean onTouchEvent(MotionEvent event) {
//        YzDebug.d("onTouchEvent :" + event.getAction() +"  "+ isEnabled() );
//        /*if(isEnabled()){
//            if (event.getAction() == MotionEvent.ACTION_DOWN){
//                if (!isChecked){
//                    setChecked(true);
//                    if (mOnCheckedChangeListener != null){
//                        mOnCheckedChangeListener.onCheckedChange(this, true);
//                    }
//                }
//            }
//        }*/
////        return super.onTouchEvent(event);
//    }


    private OnCheckedChangeListener mOnCheckedChangeListener;

    public void setOnCheckedChangeListener(OnCheckedChangeListener onCheckedChangeListener) {
        mOnCheckedChangeListener = onCheckedChangeListener;
    }

    public interface OnCheckedChangeListener{
        void onCheckedChange(PbxCircleRadioSeekBar seekBar, boolean checked);
    }

    public void setTitle(String text){
        if(mBtnTitle != null){
            mBtnTitle.setText(text);
        }
    }
}
